package com.jeff.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class UrlFilter implements Filter {


	@Override
	public void init(FilterConfig filterConfig) throws ServletException {

	}

	@Override
	public void doFilter(ServletRequest servletRequest,
			ServletResponse servletresponse, FilterChain chain)
			throws IOException, ServletException {
		chain.doFilter(servletRequest, servletresponse);
	}

	@Override
	public void destroy() {
		// TODO 自动生成的方法存根

	}
	public static boolean isNumeric(String str){
		  for (int i = 0; i < str.length(); i++){
		   System.out.println(str.charAt(i));
		   if (!Character.isDigit(str.charAt(i))){
		    return false;
		   }
		  }
		  return true;
		 }


	public String getPage(String URI, String contextPath) {

		try {
			System.out.println("输入的URI:" + URI);
			String[] sp = URI.split("/");
			if (sp.length == 0)
				return URI;
			String page = sp[sp.length - 1];
			System.out.println("AGE:" + page);
			if (URI.equalsIgnoreCase("") || URI.equalsIgnoreCase("/")
					|| URI.equalsIgnoreCase("community")) {
				URI = "/pages/admin/index.jsp?form=088f868a-8bd2-4c17-845f-9c1f94555962";
			}

		} catch (Exception e) {
			// TODO: handle exception
		}

		return URI;
	}

}
